// =============================================
// Docker Compose 模板数据
// 包含Web应用、LAMP、Halo博客等配置模板
// =============================================

// Docker Compose 模板数据
const composeTemplates = {
    'web-app': {
        name: '基础模板',
        icon: 'fas fa-cubes',
        content: `services:
   # Nginx 服务配置
   nginx:
      # 使用最新版本的 Nginx 镜像
      image: nginx:latest
      # 服务名称（通常与键名保持一致）
      service-name: nginx
      # 容器退出时总是自动重启
      restart: always
      # 使用桥接网络模式（Docker 默认网络模式）
      network_mode: bridge
      # 端口映射：将主机的 80 端口映射到容器的 80 端口
      ports:
         - 80:80
      # 数据卷挂载：将主机当前目录下的 html 文件夹挂载到容器内的 /usr/share/nginx/html 目录
      # 这样可以在主机上修改 html 文件夹中的内容，直接反映到容器内的 Nginx 网站根目录
      volumes:
         - ./html:/usr/share/nginx/html`
    },

    'lamp': {
        name: '创建模板',
        icon: 'fas fa-server',
        content: `sudo mkdir -p /vol1/1000/compose/test && cd $_ && \\
sudo cat > docker-compose.yml <<'EOF'
## 在此添加 docker-compose.yml 模板


EOF`
    },

    'halo': {
        name: 'Halo博客',
        icon: 'fas fa-blog',
        content: `services:
   halo:
      container_name: halo
      image: registry.fit2cloud.com/halo/halo:2
      restart: always
      depends_on:
         halodb:
            condition: service_healthy
      networks:
         halo_network: null
      volumes:
         - ./config/halo2:/root/.halo2
      ports:
         - 8090:8090
      healthcheck:
         test:
            - CMD
            - curl
            - -f
            - http://localhost:8090/actuator/health/readiness
         interval: 30s
         timeout: 5s
         retries: 5
         start_period: 30s
      command:
         - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
         - --spring.r2dbc.username=root
         - --spring.r2dbc.password=o#DwN&JSa56
         - --spring.sql.init.platform=mysql
         - --halo.external-url=https://www.mobufan.eu.org:666
   halodb:
      container_name: halodb
      image: mysql:8.3.0
      restart: always
      networks:
         halo_network: null
      command:
         - --default-authentication-plugin=caching_sha2_password
         - --character-set-server=utf8mb4
         - --collation-server=utf8mb4_general_ci
         - --explicit_defaults_for_timestamp=true
      volumes:
         - ./config/mysql:/var/lib/mysql
         - ./config/mysqlBackup:/data/mysqlBackup
      ports:
         - 3306:3306
      healthcheck:
         test:
            - CMD
            - mysqladmin
            - ping
            - -h
            - 127.0.0.1
            - --silent
         interval: 3s
         retries: 5
         start_period: 30s
      environment:
         - MYSQL_ROOT_PASSWORD=o#DwN&JSa56
         - MYSQL_DATABASE=halo
networks:
   halo_network: null`
    },

    'nginx-proxy': {
        name: 'Nginx 反向代理',
        icon: 'fas fa-exchange-alt',
        content: `services:
   nginx:
      image: nginx:alpine
      ports:
         - 80:80
      volumes:
         - ./nginx.conf:/etc/nginx/nginx.conf
      depends_on:
         - webapp1
         - webapp2
   webapp1:
      image: your-webapp1-image:latest
      expose:
         - "3000"
   webapp2:
      image: your-webapp2-image:latest
      expose:
         - "3000"`
    },

    'postgresql': {
        name: 'PostgreSQL',
        icon: 'fas fa-database',
        content: `services:
  postgres:
    image: postgres:13
    environment:
      POSTGRES_DB: mydb
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:`
    },

    'mongodb': {
        name: 'MongoDB',
        icon: 'fas fa-database',
        content: `services:
   mongodb:
      image: mongo:5
      environment:
         MONGO_INITDB_ROOT_USERNAME: admin
         MONGO_INITDB_ROOT_PASSWORD: password
      ports:
         - 27017:27017
      volumes:
         - mongo_data:/data/db
volumes:
   mongo_data: null`
    }
};

// Docker Compose 模板分类
const composeTemplateCategories = {
    '常用模板': {
        icon: 'fas fa-star',
        templates: ['web-app', 'lamp', 'halo', 'nginx-proxy']
    },
    '数据库模板': {
        icon: 'fas fa-database',
        templates: ['postgresql', 'mongodb']
    }
};